<?php
/**
 * Builds up a programmatic model for SQL AS clause to be used by columns & joins clauses @ SELECT query.
 */
class SQLAliasClause extends AbstractSQLClause {
	protected $strFieldName;
	protected $strFieldAlias;
	
	/**
	 * Sets up an alias clause directly from constructor. Syntax is array(name=>alias).
	 * 
	 * @example $tblLink = array("myserver.mytable"=>"t1")
	 * 
	 * @param string $strFieldName
	 * @param string $strFieldAlias
	 */
	public function __construct($strFieldName, $strFieldAlias) {
		$this->strFieldName = $strFieldName;
		$this->strFieldAlias = $strFieldAlias;
	}
	
	/**
	 * Transforms alias clause into a string.
	 * 
	 * @example mysqlserver.mytable AS t1
	 * 
	 * @return string
	 * @see AbstractSQLClause::toString()
	 */
	public function toString() {
		return $this->strFieldName." AS ".$this->strFieldAlias;
	}
}